package com.example.javafx.标签;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;

/**
 * 更新标签
 */
public class Main_7 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Button btn = new Button();
        final Label lb1 = new Label();

        primaryStage.setTitle("Hello Word");

        lb1.setLayoutX(70);
        lb1.setLayoutY(150);

        btn.setLayoutX(100);
        btn.setLayoutY(100);
        btn.setText("Hello Word!");

        btn.setOnAction(event -> {
            lb1.setText("Hello,World 文本被点击了。");
        });

        Group root = new Group();
        root.getChildren().add(btn);
        root.getChildren().add(lb1);
        primaryStage.setScene(new Scene(root,300,250));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
